function main() {
    debugger
    let searchKeywordValue = this.$$getRenderElement() && this.$$getRenderElement().params.searchKeyword || "";
    if (window.firstListChange && !searchKeywordValue) {
        document.querySelector("#card_container_7rp23v_csshandler_generate > form").__vue__.keyword = searchKeywordValue;
        this.onSearch();
        saveHistory(searchKeywordValue);
        window.firstListChange = false;
    }else{
        searchKeywordValue = document.querySelector("#card_container_7rp23v_csshandler_generate > form ").__vue__.keyword;
        saveHistory(searchKeywordValue);
    }

}

function saveHistory(keyword) {
    keyword = (keyword || "").trim();
    if (!keyword) return;
    var history = JSON.parse(localStorage.getItem("searchHistory") || "[]");

    history = history.filter(function (item) {
        return item !== keyword;
    });
    history.unshift(keyword);

    if (history.length > 5) history.pop();
    localStorage.setItem("searchHistory", JSON.stringify(history));
    renderHistory();
}

function renderHistory() {
    debugger
    var historyList = document.querySelector("#history_list");
    if (!historyList) return;

    var history = JSON.parse(localStorage.getItem("searchHistory") || "[]");
    historyList.innerHTML = "";

    if (history.length === 0) {
        historyList.innerHTML = "暂无记录";
        return;
    }

    history.forEach(function (item) {
        var tag = document.createElement("span");
        tag.style.display = "inline-block";
        tag.style.background = "#f2f2f2";
        tag.style.margin = "4px";
        tag.style.padding = "4px 10px";
        tag.style.borderRadius = "12px";
        tag.style.cursor = "pointer";
        tag.textContent = item;

        tag.onclick = function () {
            var inputEl = document.querySelector(
                "#card_container_7rp23v_csshandler_generate input[type=text]"
            );
            if (inputEl) inputEl.value = item;

            var vueForm = document.querySelector(
                "#card_container_7rp23v_csshandler_generate > form"
            );
            if (vueForm && vueForm.__vue__) {
                vueForm.__vue__.keyword = item;
            }

        };
        historyList.appendChild(tag);
    });
}
